\name{plot.IntData}
\alias{plot.IntData}
\title{Plot Method for IntData lists}
\description{A simple plot method to create interaction plots from the lists of class, "IntData" (specifically the output of \code{IntData})}
\usage{
\S3method{plot}{IntData}(x, y, ...)
}
\arguments{
  \item{x}{\code{x} should be a list of class "IntData" that contains two named data frames used to create the interaction plots.
  }
  \item{y}{\code{y} is in the generic \code{plot} but is ignored here.  Determining which variable is on the x and y axis is done by \code{IntData} prior to calculating the interaction lines.
  }
  \item{\dots}{\code{\dots} additional arguments to be passed to\code{\link[ggplot2]{geom_line}}.
  }
}
\details{This is a simple method.  All the work creating the data to plot the lines is done in \code{IntData}.  Because this method uses \pkg{ggplot2}, not many options are directly available.  Rather, the object returned should be extended and customized as any other \pkg{ggplot2} graphical object.}
\value{Returns a "ggplot" object.  Specifically with predicted lines "breaking down" a two-way interaction.}
\author{Joshua Wiley, \url{http://joshuawiley.com/}}
\note{Hopefully I will expand the notes and details soon.}
\seealso{See Also as \code{\link{IntData}}
}
\examples{
## load grid package for the unit function
require(grid)

## Various types of model interactions are show in: example(IntData)
## These examples focus on using ggplot2 to customize the output

## Demonstration Setup
oldpar <- par(no.readonly = TRUE)
par(ask = TRUE)

## Fit a linear model and use it to calculate the interaction lines
ex <- IntData(mag ~ dist * accel + event, data = attenu,
  x = "accel", intvar = "dist")

## Create the plot and store it in the object 'p'
p <- plot(ex)
## Look at the plot
print(p)

## customize the plot by using the black and white theme
## and adding more detailed x and y axis labels plus a title
p +
  theme_bw() +
  labs(x = "Earthquake Acceleration", y = "Earthquake Magnitude") +
  opts(title = "Distance x Acceleration Interaction Plot")

## Customize the plot by tweaking the legend (line length and name)
## also adding a scatter plot of the x and y data
p +
  geom_point() +
  labs(linetype = "Distance") +
  opts(legend.key.width = unit(1, "cm"))

## To change aspects of the lines, it is easiest to remake the plot
## Here with thicker lines
p <- plot(ex, size = 1)
p

## finally here is a plot with a lot of little changes
## a scatter plot is added
## the y scale is logged to make the smaller values more visible
## the theme is set to black and white
## better labels for the axes and legend are added
## a title and the length of the lines in the legend are changed

p +
  geom_point() +
  scale_y_log10() +
  theme_bw() +
  labs(x = "Earthquake Acceleration", y = "Earthquake Magnitude",
    linetype = "Distance") +
  opts(title = "Distance x Acceleration Interaction Plot",
    legend.key.width = unit(1, "cm"))

## clean up
par(oldpar)
rm(ex, p, oldpar)
}
\keyword{hplot}
